/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2022-12-22
 * Time: 20:33
 */


public class Solution {
    public boolean searchMatrix(int[][] matrix, int target) {
        int row=matrix.length;
        int col=matrix[0].length;
        int i=0;
        int j=col-1;
        while(j>=0&&i<row){
            if(matrix[i][j]==target){
                return true;
            }
            if(matrix[i][j]<target){
                //小了就往下
                i++;
            }else{
                //大了就往左
                j--;
            }
        }
        return false;
    }
}
